﻿using _111.Models;
using Microsoft.AspNetCore.Mvc;
using MyDapperApi.Models;
using MyDapperApi.Services;
using QYWXUpdate.DataModel;
using static MyDapperApi.Services.NetCommonService;

namespace MyDapperApi.Controllers;

[ApiController]
[Route("api/[controller]")]
public class NetCommonController : ControllerBase
{
    private readonly INetCommonService _netCommonService;

    public NetCommonController(INetCommonService netCommonService)
    {
        _netCommonService = netCommonService;
    }
    /// <summary>
    /// 测试服务器端地址Post方法
    /// </summary>
    /// <param name="request"></param>
    /// <returns></returns>
    [HttpPost("NetCommon")]
    public async Task<IActionResult> NetCommonPost([FromBody] NetCommonRequest request)
    {
        request.Type = 1;
        var users = await _netCommonService.PostNetCommon(request);
        return Ok(users);
    }
    /// <summary>
    /// 测试服务器端地址Get方法
    /// </summary>
    /// <param name="request"></param>
    /// <returns></returns>
    [HttpGet("NetCommon")]
    public async Task<IActionResult> NetCommonGet([FromQuery] IdRequest request)
    {
        var temp = new NetCommonRequest()
        {
            Url = request.Id,
            Type = 0
        };
        var users = await _netCommonService.PostNetCommon(temp);
        return Ok(users);
    }
}